<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of login
 *
 * @author hrza
 */
class login extends CI_Controller {
    /* Default function, when login is called, the login_form is dynamically displayed */

    function index() {
        $data['main_content'] = 'login_form';
        $this->load->view('includes/template', $data);
    }

    /* Validate user information for log in. Using login_model for this purpose */

    function validate_credentials() {

        $this->load->model('login_model');
        $query = $this->login_model->validate();

        if ($query) { // if the user credentials validated
            $data = array(
                'username' => $this->input->post('username'),
                'is_logged_in' => true
            );

            $this->session->set_userdata($data);
            redirect('login/members_area');
        } else { // user is not logged in 
            $this->index();
        }
    }

    /* When user want's to create a new account on splasher */

    function sign_up() {
        echo('Testing');
    }

}

?>
